<%--

    Document   : nhatkyht
    Created on : Oct 30, 2011, 12:34:35 PM
    Author     : Venus
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
<%@page import="java.util.*, java.text.NumberFormat,Beans.ThamSoHT,Models.ThamSoHT_Model,Models.TienTe_Model, Models.PhieuDatMA_Model"%>
<script type="text/javascript">
    function keypress(e){
        //Hàm dùng để ngăn người dùng nhập các ký tự khác ký tự số vào TextBox
        var keypressed = null;
        if (window.event)
        {
            keypressed = window.event.keyCode; //IE
        }
        else
        {
            keypressed = e.which; //NON-IE, Standard
        }
        if (keypressed < 48 || keypressed > 57 )
        { //CharCode của 0 là 48 (Theo bảng mã ASCII)
            //CharCode của 9 là 57 (Theo bảng mã ASCII)
            if (keypressed == 8 || keypressed == 127  )
            {//Phím Delete và Phím Back
                return;
            }
            return false;
        }
    }
</script>
<%
            int langid = (Integer) session.getAttribute("langid"); // ngôn ngữ hiện tại
            String dsts = " 'to', 'timehistory', 'total', 'rightmsg', 'table', 'area', 'notice', 'minutes', 'hours', 'billlist', 'bill', 'from', 'delete', 'datemsg' ";
            ThamSoHT[] mdsts = ThamSoHT_Model.DSThamSo(dsts, langid); // mảng chứa các tham số của trang này.

            String area = mdsts[0].getTenTS();
            String bill = mdsts[1].getTenTS();
            String billlist = mdsts[2].getTenTS();
            String datemsg = mdsts[3].getTenTS();
            String delete = mdsts[4].getTenTS();
            String from = mdsts[5].getTenTS();
            String hours = mdsts[6].getTenTS();
            String minutes = mdsts[7].getTenTS();
            String notice = mdsts[8].getTenTS();
            String rightmsg = mdsts[9].getTenTS();
            String table = mdsts[10].getTenTS();
            String timehistory = mdsts[11].getTenTS();
            String to = mdsts[12].getTenTS();
            String total = mdsts[13].getTenTS();

            String msgright = notice + "/" + rightmsg;
            String msgdate = notice + "/" + datemsg;
            Vector v = (Vector) request.getAttribute("DSHD");

            int numpage = 0;// khởi tạo số trang = 0
            int vsize = v.size();
            if (vsize % 10 == 0) // mỗi trang có 6 dòng
            {
                numpage = vsize / 10;
            } else {
                numpage = vsize / 10 + 1;
            }
            String xx = (String) request.getAttribute("item"); // trang hiện tại đang xem
            int item = Integer.parseInt(xx);
            String hoadon = (String) request.getAttribute("hoadon");
            String khuvuc = (String) request.getAttribute("khuvuc");
            String ban = (String) request.getAttribute("ban");
            String tongcong = (String) request.getAttribute("tongcong");
            String tungay = (String) request.getAttribute("tungay");
            String tugio = (String) request.getAttribute("tugio");
            String tuphut = (String) request.getAttribute("tuphut");
            String denngay = (String) request.getAttribute("denngay");
            String dengio = (String) request.getAttribute("dengio");
            String denphut = (String) request.getAttribute("denphut");
            NumberFormat nf = NumberFormat.getNumberInstance(Locale.FRENCH);
            int totall = 0;
%>
<script type="text/javascript">
    $(function(){
        $('#datepicker1').datepicker($.datepicker.regional['vi']);
        $( "#datepicker1" ).datepicker( "option", "dateFormat","dd/mm/yy");
        $('#datepicker2').datepicker($.datepicker.regional['vi']);
        $( "#datepicker2" ).datepicker( "option", "dateFormat","dd/mm/yy");
     });
</script>
<div id="DSHD">
    <h1><img style="margin-right: 13px; opacity: 0.8; margin-top: 5px;" alt="" src="../images/diary11.png"><%=bill %></h1>
    <div class="cb"></div>
<div class="bloc" >
    <div class="title">
        <%=billlist %>
    </div>
    <div class="content">
        <form name="dshd" action="">
            <table>
                <thead>
                    <tr>
                        <th style="width: 8%;" class="STT">                            
                            <input type="checkbox" onclick="CheckAllHD()">
                        </th>
                        <th style="width: 32%;">
                            <a href="#" id="titledskv1" style="margin-top: 5px;" class="down" lang="<%=msgright%>"  name="1" onclick="SortSearchNgayGioHD(this.className, this.name, this.lang)">
                                <div style="float:left"><%=timehistory %></div>
                                <div style=" margin-right: 200px;" id="sortkv1" class="down1"></div>
                            </a>
                        </th>
                        <th style="width: 12%;">
                            <a href="#" id="titledskv2" style="margin-top: 5px;" class="down" lang="<%=msgright%>" name="1" onclick="SortSearchSoHD( this.className, this.name, this.lang)">
                                <div style="float:left"><%=bill %></div>
                                <div style=" margin-right: 30px;" id="sortkv2" class="down1"></div>
                            </a>
                        </th>
                        <th style="width: 20%;">
                            <a href="#" id="titledskv3" style="margin-top: 5px;" class="down" lang="<%=msgright%>"  name="1" onclick="SortSearchKhuVucHD( this.className, this.name, this.lang)">
                                <div style="float:left"><%=area %></div>
                                <div style=" margin-right: 90px;" id="sortkv3" class="down1"></div>
                            </a>
                        </th>
                        <th style="width: 12%;">
                            <a href="#" id="titledskv4" style="margin-top: 5px;" class="down" lang="<%=msgright%>"  name="1" onclick="SortSearchBanHD( this.className, this.name, this.lang)">
                                <div style="float:left"><%=table %></div>
                                <div style=" margin-right: 40px;" id="sortkv4" class="down1"></div>
                            </a>
                        </th>
                        <th>
                            <a href="#" id="titledskv5" style="margin-top: 5px;" class="down" lang="<%=msgright%>"  name="1" onclick="SortSearchTongCongHD( this.className, this.name, this.lang)">
                                <div style="float:left"><%=total %></div>
                                <div style=" margin-right: 30px;" id="sortkv5" class="down1"></div>
                            </a>
                        </th>
                    </tr>
                    <tr id="searchHD">
                            <td><img onclick="SearchHD(this.alt, this.lang, this.id)" id="<%=msgdate%>" style=" margin-top: 10px; margin-bottom: -20px;" class="searchKV" alt="1" lang="<%=msgright%>" src="../images/search1.png"></td>
                            <td>
                                <div style=" width: 40px; float: left;"><%=from%></div>
                                <input type="textbox" value="<%=tungay%>" maxlength="10" class="text tungay" style=" width: 75px; margin-right: 5px; margin-bottom: 5px;" id="datepicker1">
                                <input type="textbox" value="<%=tugio%>" class="text tugio" style=" width: 25px;  margin-right: 5px;  margin-bottom: 5px;" maxlength="2" onkeypress="return keypress(event)" value="0"><%=hours%>
                                <input type="textbox" value="<%=tuphut%>" class="text tuphut" style=" width: 25px; margin-left: 5px; margin-right: 5px;  margin-bottom: 5px;" maxlength="2" onkeypress="return keypress(event)" value="0"><%=minutes%><br />
                                <div style=" width: 40px; float: left;"><%=to%></div>
                                <input type="textbox" value="<%=denngay%>" maxlength="10" class="text denngay" style=" width: 75px; margin-right: 5px; margin-bottom: 5px; " id="datepicker2">
                                <input type="textbox" value="<%=dengio%>" class="text dengio" style=" width: 25px;  margin-right: 5px; margin-bottom: 5px;" maxlength="2" onkeypress="return keypress(event)" value="0"><%=hours%>
                                <input type="textbox" value="<%=denphut%>" class="text denphut" style=" width: 25px; margin-left: 5px; margin-right: 5px; margin-bottom: 5px;" maxlength="2" onkeypress="return keypress(event)" value="0"><%=minutes%>
                            </td>
                            <td>
                                <input type="textbox" value="<%=hoadon%>" style=" width: 80px;" class="hoadon text" size="15" alt="1" lang="<%=msgright%>" onkeypress="return keypress(event)">
                            </td>
                            <td><input type="textbox" value="<%=khuvuc%>" style=" width: 120px;" class="khuvuc text" size="15" alt="1" lang="<%=msgright%>"></td>
                            <td>
                                <input type="textbox" value="<%=ban%>" style=" width: 70px;" class="ban text" alt="1" lang="<%=msgright%>" onkeypress="return keypress(event)">
                            </td>
                            <td>
                                <input type="textbox" value="<%=tongcong%>" style=" width: 100px; margin-right: 10px;" class="tongcong text" alt="1" lang="<%=msgright%>" onkeypress="return keypress(event)"><%=TienTe_Model.LayKyHieuTT(langid) %>
                            </td>
                      </tr>
                </thead>
                <tbody>
                      <%
                                    for (int i = (item - 1) * 10; i < (item - 1) * 10 + 10 && i < vsize; i++) {
                                        Beans.HoaDon hd = (Beans.HoaDon) v.elementAt(i);
                                        totall = totall + 1;
                        %>
                        <tr>                            
                            <td class="STT"><input type="checkbox" value="<%= hd.getSoHD() %>" class="optionHD" name="optionHD" ></td>
                            <td><%= hd.getGioRa() %></td>
                            <td style=" padding-left: 10px;"><a href="#"><%=hd.getSoHD() %></a></td>
                            <td><%=PhieuDatMA_Model.LayTenKV(hd.getMaBan(), langid)  %></td>
                            <td><%=PhieuDatMA_Model.LayTenBan(hd.getMaBan()) %></td>
                            <td><div style=" width: 65px; float: left; text-align: right; margin-right: 10px;"><%=nf.format(hd.getTongCong()) %></div></td>
                        </tr>
                        <%  }%>
                        <input type="hidden" name="total" value="<%=totall%>">
                </tbody>
            </table>
                <div style="float:left;">                    
                    <input type="button" style="margin-left: 0; margin-top: 5px; margin-bottom: 5px;" class="button" value ="<%=delete %>" lang="<%=msgright%>" id="1"  onclick="DeleteHD(this.id, this.lang)">
                    </div>
                <div class="pagination">
                    <%
                                int trang = 1;
                                if (item > 1) {
                                    trang = item - 1;
                                }
                    %>
                    <%
                                if (vsize > 10) {%>
                    <a href="#" class="prev" lang="<%=msgright%>" name="<%= trang%>" id="<%=msgdate%>" onclick="SearchHD(this.name, this.lang, this.id)">«</a>
                    <%
                                                        for (int c = 1; c <= numpage; c++) {
                                                            if (numpage < 10) {
                                                                if (c != item) {%>
                    <a href="#" lang="<%=msgright%>"  name="<%= c%>" id="<%=msgdate%>" onclick="SearchHD(this.name, this.lang, this.id)" ><%= c%></a>
                    <%                } else {%>
                    <a class="current"> <%= c%></a>
                    <%                }
                                                      } else {
                                                          if (c == item && item == 1) {%>
                    <a href="#" lang="<%=msgright%>" class="current"   name="<%= item%>" id="<%=msgdate%>" onclick="SearchHD(this.name, this.lang, this.id)"><%= item%></a>
                    <a href="#" lang="<%=msgright%>"   name="<%= item + 1%>" id="<%=msgdate%>" onclick="SearchHD(this.name, this.lang, this.id)"><%= item + 1%></a>
                    <a href="#" lang="<%=msgright%>"   name="<%= item + 2%>" id="<%=msgdate%>" onclick="SearchHD(this.name, this.lang, this.id)"><%= item + 2%></a>
                    <a href="#" lang="<%=msgright%>"   name="<%= item + 3%>" id="<%=msgdate%>" onclick="SearchHD(this.name, this.lang, this.id)"><%= item + 3%></a>
                    ...
                    <a href="#" lang="<%=msgright%>"   name="<%= numpage - 3%>" id="<%=msgdate%>" onclick="SearchHD(this.name, this.lang, this.id)"><%= numpage - 3%></a>
                    <a href="#" lang="<%=msgright%>"   name="<%= numpage - 2%>" id="<%=msgdate%>" onclick="SearchHD(this.name, this.lang, this.id)"><%= numpage - 2%></a>
                    <a href="#" lang="<%=msgright%>"   name="<%= numpage - 1%>" id="<%=msgdate%>" onclick="SearchHD(this.name, this.lang, this.id)"><%= numpage - 1%></a>
                    <a href="#" lang="<%=msgright%>"   name="<%= numpage%>" id="<%=msgdate%>" onclick="SearchHD(this.name, this.lang, this.id)"><%= numpage%></a>
                    <%            }
                                                          if (c == item && item != 1) {
                                                              if (item < (numpage / 2)) {%>

                    <a href="#" lang="<%=msgright%>"   name="<%= item - 1%>" id="<%=msgdate%>" onclick="SearchHD(this.name, this.lang, this.id)"><%= item - 1%></a>
                    <a href="#" lang="<%=msgright%>" class="current"  name="<%= item%>" id="<%=msgdate%>" onclick="SearchHD(this.name, this.lang, this.id)"><%= item%></a>
                    <a href="#" lang="<%=msgright%>"   name="<%= item + 1%>" id="<%=msgdate%>" onclick="SearchHD(this.name, this.lang, this.id)"><%= item + 1%></a>
                    <a href="#" lang="<%=msgright%>"   name="<%= item + 2%>" id="<%=msgdate%>" onclick="SearchHD(this.name, this.lang, this.id)"><%= item + 2%></a>

                    ...
                    <a href="#" lang="<%=msgright%>"   name="<%= numpage - 3%>" id="<%=msgdate%>" onclick="SearchHD(this.name, this.lang, this.id)"><%= numpage - 3%></a>
                    <a href="#" lang="<%=msgright%>"   name="<%= numpage - 2%>" id="<%=msgdate%>" onclick="SearchHD(this.name, this.lang, this.id)"><%= numpage - 2%></a>
                    <a href="#" lang="<%=msgright%>"   name="<%= numpage - 1%>" id="<%=msgdate%>" onclick="SearchHD(this.name, this.lang, this.id)"><%= numpage - 1%></a>
                    <a href="#" lang="<%=msgright%>"   name="<%= numpage%>" id="<%=msgdate%>" onclick="SearchHD(this.name, this.lang, this.id)"><%= numpage%></a>
                    <%                }%>
                    <%                                     if (item >= (numpage / 2) && item != numpage) {
                                                              int start = 1;
                    %>
                    <a href="#" lang="<%=msgright%>"   name="<%= start%>" id="<%=msgdate%>" onclick="SearchHD(this.name, this.lang, this.id)"><%= start%></a>
                    <a href="#" lang="<%=msgright%>"   name="<%= start + 1%>" id="<%=msgdate%>" onclick="SearchHD(this.name, this.lang, this.id)"><%= start + 1%></a>
                    <a href="#" lang="<%=msgright%>"   name="<%= start + 2%>" id="<%=msgdate%>" onclick="SearchHD(this.name, this.lang, this.id)"><%= start + 2%></a>
                    <a href="#" lang="<%=msgright%>"   name="<%= start + 3%>" id="<%=msgdate%>" onclick="SearchHD(this.name, this.lang, this.id)"><%= start + 3%></a>
                    ...
                    <a href="#" lang="<%=msgright%>"   name="<%= item - 2%>" id="<%=msgdate%>" onclick="SearchHD(this.name, this.lang, this.id)"><%= item - 2%></a>
                    <a href="#" lang="<%=msgright%>"   name="<%= item - 1%>" id="<%=msgdate%>" onclick="SearchHD(this.name, this.lang, this.id)"><%= item - 1%></a>
                    <a href="#" lang="<%=msgright%>" class="current"  name="<%= item%>" id="<%=msgdate%>" onclick="SearchHD(this.name, this.lang, this.id)"><%= item%></a>
                    <a href="#" lang="<%=msgright%>"   name="<%= item + 1%>" id="<%=msgdate%>" onclick="SearchHD(this.name, this.lang, this.id)"><%= item + 1%></a>
                    <%                }
                    %>
                    <%                                     if (item >= (numpage / 2) && item == numpage) {
                                                              int start = 1;
                    %>
                    <a href="#" lang="<%=msgright%>"   name="<%= start%>" id="<%=msgdate%>" onclick="SearchHD(this.name, this.lang, this.id)"><%= start%></a>
                    <a href="#" lang="<%=msgright%>"   name="<%= start + 1%>" id="<%=msgdate%>" onclick="SearchHD(this.name, this.lang, this.id)"><%= start + 1%></a>
                    <a href="#" lang="<%=msgright%>"   name="<%= start + 2%>" id="<%=msgdate%>" onclick="SearchHD(this.name, this.lang, this.id)"><%= start + 2%></a>
                    <a href="#" lang="<%=msgright%>"   name="<%= start + 3%>" id="<%=msgdate%>" onclick="SearchHD(this.name, this.lang, this.id)"><%= start + 3%></a>
                    ...
                    <a href="#" lang="<%=msgright%>"   name="<%= item - 3%>" id="<%=msgdate%>" onclick="SearchHD(this.name, this.lang, this.id)"><%= item - 3%></a>
                    <a href="#" lang="<%=msgright%>"   name="<%= item - 2%>" id="<%=msgdate%>" onclick="SearchHD(this.name, this.lang, this.id)"><%= item - 2%></a>
                    <a href="#" lang="<%=msgright%>"   name="<%= item - 1%>" id="<%=msgdate%>" onclick="SearchHD(this.name, this.lang, this.id)"><%= item - 1%></a>
                    <a href="#" lang="<%=msgright%>" class="current"  name="<%= item%>" id="<%=msgdate%>" onclick="SearchHD(this.name, this.lang, this.id)"><%= item%></a>

                    <%                }
                    %>
                    <%            }
                                                            }
                                                        }
                    %>
                    <%
                                                        if (item + 1 <= numpage) {
                                                            trang = item + 1;
                                                        } else {
                                                            trang = item;
                                                        }
                    %>
                    <a href="#" lang="<%=msgright%>" class="next"  name="<%= trang%>" id="<%=msgdate%>" onclick="SearchHD(this.name, this.lang, this.id)">»</a>
                    <%  }
                    %>
                </div>
            </form>

    </div>
</div>
</div>